home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Mac / IDE scripts / Hack / Toolbox Assistant… < prev   
Encoding:
Text File  |  2000-06-23  |  1.1 KB  |  46 lines

  1. import aetools
  2. import Standard_Suite
  3. import Required_Suite
  4. import MacOS
  5. import W
  6.  
  7.  
  8. class Toolbox(aetools.TalkTo, Standard_Suite.Standard_Suite):
  9.     
  10.     def LookupTopic(self, _object, _attributes={}, **_arguments):
  11.         _code = 'DanR'
  12.         _subcode = 'REF '
  13.  
  14.         _arguments['----'] = _object
  15.         
  16.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  17.                 _arguments, _attributes)
  18.         if _arguments.has_key('errn'):
  19.             raise MacOS.Error, aetools.decodeerror(_arguments)
  20.     
  21.  
  22. class ToolboxAssi:
  23.     
  24.     def __init__(self):
  25.         self.talker = None
  26.         self.w = W.Window((200, 100), "Toolbox Assistant")
  27.         self.w.button = W.Button((-94, -32, 80, 16), "Lookup", self.lookup)
  28.         self.w.prompt = W.TextBox((10, 8, -10, 15), "Enter topic:")
  29.         self.w.edit = W.EditText((10, 24, -10, 20))
  30.         self.w.setdefaultbutton(self.w.button)
  31.         self.w.open()
  32.     
  33.     def lookup(self):
  34.         if self.talker is None:
  35.             try:
  36.                 self.talker = Toolbox('ALTV', start = 1)
  37.             except:
  38.                 raise W.AlertError, "Can’t find “Toolbox Assistant”"
  39.         lookup = self.w.edit.get()
  40.         try:
  41.             self.talker.LookupTopic(lookup)
  42.         except MacOS.Error, detail:
  43.             W.Message("Requested topic not found.\r(%d)" % detail[0])
  44.  
  45. t = ToolboxAssi()
  46.